﻿/*
 * 由SharpDevelop创建。
 * 用户： xieen
 * 日期: 2013-08-14
 * 时间: 10:50
 * 
 * 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
 */
using System;

namespace GoF23Learning._02.Abstract_Factory
{
	//员工的工资 = (基本工资 + 奖金 - 个人所得税)
	/*
	 chongqing  奖金 = 基本工资(3000) * 10%
	   
       个人所得税 = (基本工资 + 奖金) * 40%
       
       
        上海     
奖金 = 基本工资 (6000)* 15 %

个人所得税 = (基本工资 * 5% + 奖金 * 25%)  
       
	 */
	/// <summary>
	/// Description of EmployeeWages.
	/// </summary>
	public class EmployeeWages
	{
		public EmployeeWages()
		{
		}
		/// <summary>
		/// 获取基本工资
		/// </summary>
		/// <param name="areaType"></param>
		/// <returns></returns>
		public double  GetBaseSalary(string areaType)
		{
			double  baseSalary = 0;
			switch (areaType.ToLower()) {
				case "shanghai":
					baseSalary = 6000d;
					break;
				case "chongqing":
					baseSalary = 3000d;
					break;
				default:
					break;
			}
			Console.WriteLine(baseSalary);			
			return baseSalary;			
			
		}

		/// <summary>
		/// 获取奖金
		/// </summary>
		/// <param name="areaType">区域</param>
		/// <param name="baseSalary">基本工资</param>
		/// <returns></returns>
		public double GetBonus(string areaType,double	baseSalary )
		{
				if (areaType == null)
				throw new ArgumentNullException("areaType");

			double  bonus = 0;
			switch (areaType.ToLower()) {
				case "shanghai":
					bonus = baseSalary*0.35;
					break;
				case "chongqing":
					bonus = baseSalary*0.10;
					break;
				default:
					break;
			}
			Console.WriteLine(bonus);			
			return bonus;			
		}
		/// <summary>
		/// 获取个人所得税
		/// </summary>
		/// <param name="areaType">区域</param>
		/// <param name="baseSalary">基本工资</param>
		/// <param name="bonus">奖金</param>
		/// <returns></returns>
		public double GetTax(string areaType, double baseSalary,double bonus)
		{
			if (areaType == null)
				throw new ArgumentNullException("areaType");
			double  tax = 0;
			switch (areaType.ToLower()) {
				case "shanghai":
					tax = baseSalary*0.05+bonus*0.20;
					break;
				case "chongqing":
					tax = (baseSalary+bonus)*0.40;
					break;
				default:
					break;
			}
			
			Console.WriteLine(tax);			
			return tax;	
		}
		public double GetWages(string areaType)
		{
			double result = 0;
			double baseSalary;
			double bonus;
			double tax;
		 
					baseSalary = GetBaseSalary(areaType);
					bonus = GetBonus(areaType,baseSalary);
					tax = GetTax(areaType,baseSalary,bonus);
				 
			
			result =baseSalary+bonus-tax ;
			
			Console.WriteLine(result);
			
			return result;
			
		}
	}
}
